home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Palettes / TablePrinter / TablePrintPanel.m < prev   
Text File  |  1995-06-12  |  2KB  |  65 lines

  1.  
  2. // TablePrintPanel
  3. //
  4. // By Eric T. Seymour, NeXT Computer, Inc.
  5. //
  6. // TablePrintPanel lets you set the pages per row, so
  7. // that it will adjust the total pages sent to reflect the root page.
  8. // For instance, if I asked to print from 2 to 2 on a table that was three
  9. // pages wide, It would set PrintInfo to print 4 through 6.
  10. //
  11. // You may freely copy, distribute, and reuse the code in this example.
  12. // NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  13. // fitness for any particular use.
  14. //
  15. // This file looks best when using tabstops of 3.
  16.  
  17.  
  18. #import "TablePrintPanel.h"
  19.  
  20. @implementation TablePrintPanel:PrintPanel
  21.  
  22. + new
  23. {
  24.     self = [super new];
  25.     pagesPerRow = 1;
  26.     return self;
  27. }
  28.  
  29. - setPagesPerRow:(int)pages
  30. {
  31.     pagesPerRow = pages;
  32.     return self;
  33. }
  34. - (int)pagesPerRow {return pagesPerRow;}
  35.  
  36. // Override finalWritePrintInfo to adjust the pages to print to reflect
  37. // the number of pages wide a table might be
  38.  
  39. - finalWritePrintInfo
  40. {
  41.     int    originalNumber;
  42.     id        returnId = [super finalWritePrintInfo];
  43.  
  44.     // Determine the pages to print based on number of pages per row
  45.     // and adjust the printinfo object
  46.     if ( ![[pageMode cellAt:0:0] state] && pagesPerRow > 1 )
  47.     {
  48.         if ( originalNumber = [firstPage intValue] )
  49.         {
  50.             if ( originalNumber >= 1 ) originalNumber--;
  51.             else originalNumber = 0;
  52.             [[NXApp printInfo] setFirstPage:(originalNumber * pagesPerRow) + 1];
  53.         }
  54.         if ( originalNumber = [lastPage intValue] )
  55.             [[NXApp printInfo] setLastPage:(originalNumber * pagesPerRow)];
  56.     }
  57.     // Reset PagesPerRow.  This must be set for each call to printPSCode.
  58.     pagesPerRow = 1;
  59.  
  60.     return returnId;
  61. }
  62.  
  63. @end
  64.  
  65.